<template>
    <Row :gutter="40">
        <Col :span="8">
        <Form.Item label="名称：">
            <Input v-model:value="formData.name" placeholder="请填写名称" />
        </Form.Item>
        </Col>
        <Col :span="8">
        <Form.Item label="描述：">
            <Input v-model:value="formData.description" placeholder="请填写描述" />
        </Form.Item>
        </Col>
        <Col :span="8">
        <Form.Item label="参数：">
            <Input v-if="isInner" v-model:value="formData.parameter" placeholder="请填写参数" />
            <Input v-else v-model:value="formData.beanShellParam" placeholder="请填写参数" />
        </Form.Item>
        </Col>
    </Row>
    <Form.Item label="脚本文件：">
        <UploadFile v-if="isInner" :show-url="formData.fileName" @change="$event.file.response &&
                                (formData.fileName =
                                    $event.file.response.data)">
            <Button>{{ !!formData.fileName ? '已上传' : '未上传' }} </Button>
        </UploadFile>
        <UploadFile v-else :show-url="formData.beanShellFileName" @change="$event.file.response &&
                                (formData.beanShellFileName =
                                    $event.file.response.data)">
            <Button>{{ !!formData.beanShellFileName ? '已上传' : '未上传' }} </Button>
        </UploadFile>
    </Form.Item>
    <Form.Item label="脚本：">
        <Textarea  v-if="isInner" v-model:value="formData.script" :rows="6" placeholder="请填写脚本" />
        <Textarea  v-else v-model:value="formData.beanShellQuery" :rows="6" placeholder="请填写脚本" />
    </Form.Item>
</template>
 
<script lang="ts" setup>
import {
    Button,
    Form,
    Row,
    Col,
    Input,
    Textarea,
} from 'ant-design-vue'
import {
    type IStressCaseBeanShell,
    type IStressCaseBeanShellInner
} from '~/types/apis/stress-case'


const formData = defineModel<IStressCaseBeanShell | IStressCaseBeanShellInner>('formData', { required: true })



const props = withDefaults(
    defineProps<{
        isInner: boolean
    }>(),
    {
        isInner: false,
    },
)
</script>
 
<style lang="scss" scoped></style>